package cn.edu.scau.cmi.wujiaxian.exercise10;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Example10_7 {
	
	//BufferedWriter 和 BufferedReader支持一行的读写操作
	public static void main(String[] args) {
		File file = new File("Student.txt");
		String[] content = {"商品列表：", "电视机，2567元/台", "洗衣机，3562元/台"};
 		try {
			BufferedWriter out  = new BufferedWriter(
					new FileWriter(file));
			for (String s : content) {
				out.write(s);
				out.newLine();
			}
			out.close();
			BufferedReader in = new BufferedReader(
					new FileReader(file));
			String s = null;
			while ((s = in.readLine()) != null) {
				System.out.println(s);
			}
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
}
